<template>
  <div id="app-container">
    <el-row :gutter="20">
      <el-col :span="7.6">
        <div class="grid-content bg-purple">
          <label>查询订单的日期</label>
          <el-date-picker
            v-model="period"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </div>
      </el-col>
      <el-col :span="3.6">
        <div class="grid-content bg-purple">
          <el-button type="primary" icon="el-icon-search" @click="searchOrder">搜索</el-button>
          <el-button class="el-icon-refresh-left">重置</el-button>
        </div>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <el-button type="warning" class="el-icon-download" plain>导出</el-button>
      </el-col>
    </el-row>
    <el-row>
      <el-table :data="ordersList"
                style="width: 100%">
        <el-table-column type="selection" width="50"></el-table-column>
        <el-table-column label="医生id" prop="doctId" align="center"></el-table-column>
        <el-table-column label="医生姓名" prop="doctName" align="center"></el-table-column>
        <el-table-column label="订单数量" prop="orderQuantity" align="center"></el-table-column>
        <el-table-column label="订单金额" prop="money" align="center"></el-table-column>
        <el-table-column label="充值总额" prop="totalMoney" align="center"></el-table-column>
        <el-table-column label="操作" align="center">
          <template slot-scope="scope">
            <el-button
              size="mini"
              icon="el-icon-edit"
              @click="handleEdit(scope.$index, scope.row)">详情
            </el-button>
          </template>
        </el-table-column>
      </el-table>
    </el-row>
    <el-row :gutter="5">
      <!--   offset偏移制定栏数     -->
      <el-col :span="4.8" :offset="15">
        <div class="grid-content bg-purple">
          <label>共{{ totalStrip }}条</label>
          <el-select v-model="value" style="width: 100px">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
              :disabled="item.disabled">
            </el-option>
          </el-select>
        </div>
      </el-col>
      <el-col :span="4.2">
        <div class="grid-content bg-purple">
          <el-pagination
            background
            style="margin: auto "
            layout="prev, pager, next"
            :total="50">
          </el-pagination>
        </div>
      </el-col>
      <el-col :span="2.4">
        <div class="grid-content bg-purple">
          <label>前往&nbsp;&nbsp;
            <el-input style="width: 40px" v-model="inputnum"></el-input>&nbsp;&nbsp;
            页</label>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
//Day.js 是一个轻量的处理时间和日期的 JavaScript 库，和 Moment.js 的 API 设计保持完全一样。
import dayjs from 'dayjs';
import {queryOrderByTime} from "@/api/system/order"

export default {
  name: 'index',
  data() {
    return {
      ordersList: [],
      //  Date对象数组
      period: [new Date(2021, 10, 14, 8, 0, 0), new Date(2021, 12, 31, 8, 0, 0)],
      beginTime: '',
      endTime: '',
      periods:
        {
          startTime: '',
          endTime: '',
        },
      totalStrip: 234,
      options: [{
        value: 1,
        label: '10条/页'
      },
        {
          value: 2,
          label: '10条/页'
        },
      ],
      value: '10条/页',
      inputnum: null,
    }
  },
  methods: {
    ListOrder() {
      queryOrderByTime().then(response => {
          // console.log(response);
          this.ordersList = response;
        }
      )
    },
    searchOrder() {
      this.periods.startTime = dayjs(this.period[0]).format("YYYY-MM-DD HH:mm:ss");
      this.periods.endTime = dayjs(this.period[1]).format("YYYY-MM-DD HH:mm:ss");
      console.log(this.periods);
      queryOrderByTime(this.periods).then(response => {
          console.log(response);
          this.ordersList = response;
        }
      )
    }
//  Postman用开始时间测试一切正常
  },
  created() {
    this.ListOrder();
  }
}


</script>

<style>
#app-container {
  margin: 10px;
}


.page {
  height: 30px;
  width: 15px;
  text-align: center;
}

.inputs {
  width: 200px;
  height: 30px;
}


.el-row {
  margin-bottom: 20px;

&
:last-child {
  margin-bottom: 0;
}

}
.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #ffffff;
}

.bg-purple {
  background: #fcfcfc;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

label {
  display: inline-block;
  float: left;
  font-family: sans-serif;
  height: auto;
  line-height: 36px;
  padding-right: 5px;
  padding-left: 5px;
}


</style>
